<?php
namespace app\attendance;
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/6/9 0009
 * Time: 下午 4:28
 */

use think\Controller;
use think\Config; 

use com\gdl\newagk\interfaces\AuthorityServiceClient;
use com\gdl\newagk\dataobject\authority\AuthorityRequestDTO; 
use com\gdl\newagk\dataobject\authority\AuthorityDTO;

class Base extends Controller
{ 


    public function __construct()
    {
		
         parent::__construct();
         $this->time = time();
		  
		 header('Access-Control-Allow-Origin:*');
        // 响应类型  
        header('Access-Control-Allow-Methods:*');
        // 响应头设置  
        header('Access-Control-Allow-Headers:x-requested-with,content-type');
    }
  
    
	
	
	public function _initialize(){


//		$adminuserid = $this->request->param('adminuserid') ? $this->request->param('adminuserid') : 0;
//		$reg = $this->request->param('reg') ? getStr($this->request->param('reg')) : '';
//		$roleid =$this->request->param('roleid') ? $this->request->param('roleid') : 0; //权限组id
//		$module = request()->module();
//		$controllers = strtoupper(request()->controller());
//		$actions = strtoupper(request()->action());
//
//
//
//		if(!empty($reg) && $adminuserid){
//			/******判断是否有大模块的权限******/
//
//			try {
//				\ApiClient::init(Config::get('api.appid'), Config::get('api.secret'), 30, array('gdlAgkSdk'));
//				$api = new AuthorityServiceClient(NULL);
//
//				\ApiClient::build($api);
//				$engprojectDo = new AuthorityDTO();
//				$engprojectDo->userid = $adminuserid;
//				$engprojectDo->reg = $reg;
//				$engprojectDo->roleid = $roleid;
//				$result = $api->verRbac($engprojectDo); //获取权限列表和管理员标识
//
//				if($result->code){
//					/*****测试原型*****/
//					$nodes = $result->data;
//
//					$tree_node = list_to_tree($nodes); //转化为标准列 必须转不然不能区分控制器和方法
//					$menu = [];
//					$groups_id = [];
//					/*
//					foreach ($tree_node as $module) {
//						if ($module['pid'] == 0 && strtoupper($module['name']) == strtoupper($this->request->module())) {
//							if (isset($module['_child'])) {
//								foreach ($module['_child'] as $controller) {
//									$group_id = $controller['group_id'];
//									array_push($groups_id, $group_id);
//									$menu[$group_id][] = $controller;
//								}
//							}
//						}
//					}
//					*/
//					$treeToMulti = \Rbac::treeToMultiArray($tree_node, "name", "id", "_child"); //将权限列 转为 只剩下 控制器 方法的 权限树
//					$not_auth_module = []; //不需要验证
//					if (
//						Config::get('rbac.user_auth_on') &&
//						!in_array(strtoupper($module), $not_auth_module)
//					) {
//
//						if (!\Rbac::AccessChecks($result->message,$treeToMulti,$userid) && !in_array($actions, array('ajaxchangeallow'))) {
//
//							$data = ['msg'=>"没有权限",'code'=>'500','data'=>[]];
//							exit(json_encode($data));
//						}
//					}
//				} else {
//					$data = ['msg'=>$result->message,'code'=>'400','data'=>[]];
//					exit(json_encode($data));
//				}
//			} catch (Exception $ex) {
//				$data = ['msg'=>'权限拉取失败','code'=>'500','data'=>[]];
//					exit(json_encode($data));
//			}
//
//
//		} else {
//
//			$data = ['msg'=>'参数异常','code'=>'500','data'=>[]];
//			exit(json_encode($data));
//		}
		
    }
	



}
